<%@ page import="javax.servlet.jsp.JspWriter" pageEncoding="utf-8"%>
<%@ page import="com.cpkf.yyjd.hachi.monitor.ClusterStatusMonitor"%>
<%@ page import="com.cpkf.yyjd.hachi.monitor.JobMonitorInfo"%>
<%@ page language="java" import="java.util.*" %>
<%
  String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>关闭系统</title>
<link href="<%=path%>/css/form.css" rel="stylesheet" type="text/css"/>
<link href="<%=path%>/css/font.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" language="javascript">
   setInterval( function(){ 
		 location.reload();
	}, 20000);
   </script>
</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="3">
	<!--Start top-->
	<jsp:include page="/page/top.jsp" /></td>
  </tr>
  <tr>
    <td width="194" valign="top">	<!--Start left-->
        <jsp:include page="/page/left_menu_admin.jsp" />  
    <!--End left--></td>
    <td width="20">&nbsp;</td>
    <td width="799" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="39" class="titletop" style="border-bottom:1px dotted #ccc;" ></td>
      </tr>
    </table>
      <br/>
      <br/> <br/><br/>
    <table width="100%">
     <tr>
       <td>


    <table border="2" cellspacing="1" cellpadding="3">
    <hr/>
    <tr>
    	<td><b>任务ID</b></td>
    	<td><b>IP地址</b></td>
    	<td><b>子节点</b></td>
    	<td><b>任务状态</b></td>
    </tr>
    
    <%
        	List<JobMonitorInfo> jobinfos = ClusterStatusMonitor.getJobInfo();
        	if (jobinfos != null) {
        		for (int i = 0; i < jobinfos.size(); i++) {
        			JobMonitorInfo jminfo = (JobMonitorInfo) jobinfos.get(i);
        			List<String> childs = jminfo.getChilds();
        			String childstr = "";
        			if (childs != null && childs.size() > 0) {
        				for (int j = 0; j < childs.size(); j++) {
        					childstr = childstr + childs.get(i) + ",";
        				}
        				if (!childstr.equals("")) {
        					childstr.substring(0, childstr.length() - 1);
        				}
        			} else {
        				childstr = "-";
        			}
        %>
	    <tr>
	        <td><%=jminfo.getJobid()%></td>
	    	<td><%=jminfo.getMaster().toString()%></td>
	    	<td><%=childstr%></td>
	    	<td><%=jminfo.getJobstatus().toString()%></td>
	    </tr>
    
    <%
        	}
        	}
        %>
    
   </table>
   <!--历史的信息  -->
      <table border="2" cellspacing="1" cellpadding="3">
    <hr/>
    <tr>
    	<td><b>历史任务ID</b></td>
    	<td><b>IP地址</b></td>
    	<td><b>子节点</b></td>
    	<td><b>任务状态</b></td>
    </tr>
    
    <%
        	List<JobMonitorInfo> histroyjobinfos = ClusterStatusMonitor.getHistroyJobInfo();
        	if (histroyjobinfos != null) {
        		for (int i = 0; i < histroyjobinfos.size(); i++) {
        			JobMonitorInfo jminfo = (JobMonitorInfo) histroyjobinfos.get(i);
        			List<String> childs = jminfo.getChilds();
        			String childstr = "";
        			if (childs != null && childs.size() > 0) {
        				for (int j = 0; j < childs.size(); j++) {
        					childstr = childstr + childs.get(i) + ",";
        				}
        				if (!childstr.equals("")) {
        					childstr.substring(0, childstr.length() - 1);
        				}
        			} else {
        				childstr = "-";
        			}
        %>
	    <tr>
	        <td><%=jminfo.getJobid()==null?"":jminfo.getJobid()%></td>
	    	<td><%=jminfo.getMaster()==null?"":jminfo.getMaster().toString()%></td>
	    	<td><%=childstr%></td>
	    	<td><%=jminfo.getJobstatus()==null?"":jminfo.getJobstatus().toString()%></td>
	    </tr>
    
    <%
        	   }
        	}
        %>
        </td>
	  </tr>	  
	 </table>
    </td>
  </tr>
</table>
</body>
</html>